import { ReceiveMessageType } from "/@/config/DeclareGlobal";
import ReceiveMessage from "/@/core/communication/ReceiveMessage";

//选中物体时会发送这个物体的所有信息
export const selectedInfo = (callback) => {
  // 不再直接添加监听器，而是检查监听器是否存在
  // 这样可以避免与basicComponent.vue中的监听器冲突
  if (!ReceiveMessage.hasListener(ReceiveMessageType.SelectedInfo)) {
    ReceiveMessage.addListener(ReceiveMessageType.SelectedInfo, (e) => {
      callback(e.data);
    });
  }
};

//unity初始化完成时会发送一个消息告知已经初始化完成
export const Initialized = (callback) => {
  ReceiveMessage.addListener(ReceiveMessageType.Initialized, () => callback());
};
